package thread;

/**
 * 线程礼让测试
 *
 * @author dingwen
 * @date 2021/09/05
 */
public class TestYield implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"开始执行");
        Thread.yield();
        System.out.println(Thread.currentThread().getName()+"开始执行");
    }

    public static void main(String[] args) {
        TestYield testYield = new TestYield();
        new Thread(testYield,"线程1").start();
        new Thread(testYield,"线程2").start();
    }
}
